package com.mzj.saas.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.ApartmentOrderChargeItem;
import com.haixiaoke.saas.repository.service.IApartmentOrderChargeItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公寓订单独有收费项目Controller
 *
 * @author qixi
 * @date 2023-06-16
 */
@RestController
@RequestMapping("/business/item")
public class    ApartmentOrderChargeItemController extends BaseController {
    @Autowired
    private IApartmentOrderChargeItemService apartmentOrderChargeItemService;

    /**
     * 查询公寓订单独有收费项目列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ApartmentOrderChargeItem apartmentOrderChargeItem) {
        startPage();
        List<ApartmentOrderChargeItem> list = apartmentOrderChargeItemService.selectApartmentOrderChargeItemList(apartmentOrderChargeItem);
        return getDataTable(list);
    }

    /**
     * 获取公寓订单独有收费项目详细信息
     */
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId) {
        return success(apartmentOrderChargeItemService.selectApartmentOrderChargeItemByItemId(itemId));
    }

    /**
     * 新增公寓订单独有收费项目
     */
    @PostMapping
    public AjaxResult add(@RequestBody ApartmentOrderChargeItem apartmentOrderChargeItem) {
        return toAjax(apartmentOrderChargeItemService.insertApartmentOrderChargeItem(apartmentOrderChargeItem));
    }

    /**
     * 修改公寓订单独有收费项目
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ApartmentOrderChargeItem apartmentOrderChargeItem) {
        return toAjax(apartmentOrderChargeItemService.updateApartmentOrderChargeItem(apartmentOrderChargeItem));
    }

    /**
     * 删除公寓订单独有收费项目
     */
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable Long[] itemIds) {
        return toAjax(apartmentOrderChargeItemService.deleteApartmentOrderChargeItemByItemIds(itemIds));
    }
}
